package com.east.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.websocket.server.ServerEndpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author Administrator
 *
 */
@ControllerAdvice
public class ExceptionHandle {
	private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);

	/**
	 * 判断错误是否是已定义的已知错误，不是则由未知错误代替，同时记录在log中
	 * 
	 * @param e
	 * @return
	 */
	@ExceptionHandler(value = Exception.class)
	public void handle(HttpServletResponse response,HttpServletRequest request,Exception e){
		ExceptionUtil.exception(logger, response,request, e);
		System.out.println("======================="+request.getServletPath());
		System.out.println(request.getMethod());
		//ExceptionUtil.outError(logger,response,ResultEnums.error_500.getCode(),ExceptionUtils.getStackTrace(e));
		return;
	}
	
}
